package com.mx.recycle_adapt.activity

import android.graphics.Color
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mx.adapt.picker.IMXSelect
import com.mx.recycle_adapt.R
import kotlinx.android.synthetic.main.activity_scroller_view.*
import kotlin.random.Random

class ScrollerViewActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_scroller_view)

        scrollerView2.setItemSize(5)
        scrollerView2.setOnSelectListener(object : IMXSelect {
            override fun onSelect(index: Int) {
                infoTxv.text = index.toString()
            }
        })
        scrollerView2.setDashColor(Color.parseColor("#33465FCD"))

        addTxv.setOnClickListener {
            scrollerView2.adapt.list.removeLastOrNull()
            scrollerView2.adapt.notifyDataSetChanged()
        }
        scrollerView2.setData((0 until 13).map { it.toString() })
        scrollerView2.setSelectIndex(100)
        scrollerView2.setAnimationDuration(500)
        scrollTxv.setOnClickListener {
            val indx = Random.nextInt(scrollerView2.adapt.list.size)
            scrollerView2.setSelectIndex(indx, true)
            scrollerView2.setSelectIndex(indx, true)
        }

        scrollerView2.setListItemProcess { _, _, textView ->
            textView.setTextColor(Color.BLUE)
        }
    }
}